﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ChoDiaOc_HK_WPF.Models;

namespace ChoDiaOc_HK_WPF.Controls {
    public partial class HuyDangKyController {

        private static HuyDangKyController controller = null;

        public static HuyDangKyController GetInstance() {
            if (controller == null) {
                controller = new HuyDangKyController();
            }
            return controller;
        }

        private HuyDangKyController() {
        }

        private PHIEUDANGKY phieuDangKy;

        public PHIEUDANGKY PhieuDangKy {
            get { return phieuDangKy; }
            set { phieuDangKy = value; }
        }

        private KHACHHANG khachHang;

        public KHACHHANG KhachHang {
            get { return khachHang; }
            set { khachHang = value; }
        }

        private DIAOC diaOc;

        public ChoDiaOc_HK_WPF.DIAOC DiaOc {
            get { return diaOc; }
            set { diaOc = value; }
        }
        private LOAIDIAOC loaiDiaOc;

        public ChoDiaOc_HK_WPF.LOAIDIAOC LoaiDiaOc {
            get { return loaiDiaOc; }
            set { loaiDiaOc = value; }
        }
  
        public bool Huy() {           
            phieuDangKy.DenNgay = phieuDangKy.TuNgay.Subtract(new TimeSpan(1, 0, 0));
            diaOc.TrangThai = "Đã bán";
            return (DatabaseWrapper.GetInstance().UpdatePhieuDangKy(phieuDangKy.MaPhieuDangKy, phieuDangKy.DenNgay) && DatabaseWrapper.GetInstance().UpdateDiaOc(diaOc.MaDiaOc, diaOc.TrangThai));
        }

        
    }
}
